﻿using HCQ2_IBLL;
using HCQ2_Model;
using HCQ2_Model.VR.Params;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_BLL
{
    public partial class T_VRUserLevelLogBLL: IT_VRUserLevelLogBLL
    {
        /// <summary>
        ///  验证用户是否需要重新计算用户等级
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public int CheckCountScore(int user_id)
        {
            return DBSession.IT_VRUserLevelLogDAL.CheckCountScore(user_id);
        }
        /// <summary>
        ///  重新计算用户等级
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public int ResetUserLevel(int user_id, int folder_id, int year)
        {
            //1.获取下线人数
            int lineNum = DBSession.IT_VRFounderApplyDAL.SelectCount(s => s.ref_id == user_id && s.folder_id == folder_id && s.apply_status == 1);
            //2.获取销售金额
            decimal sellNum = DBSession.IT_VRUserLevelLogDAL.getSellNum(user_id,year);
            //3.确定用户等级
            return DBSession.IT_VRUserLevelLogDAL.getUserLevel(lineNum, sellNum, folder_id);
        }
        /// <summary>
        /// 获取用户等级日志列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<UserLevelLog> GetUserLevelLog(UserLevelLogParam param, out int total)
        {
            return DBSession.IT_VRUserLevelLogDAL.GetUserLevelLog(param, out total);
        }
    }
}